﻿
(function (window) {
    function Spell(spellId) {
        this.initialize(spellId);
    }
    var p = Spell.prototype = new createjs.Container();
    p.bm = null;
    p.containerScale =null;
    p.Container_initialize = p.initialize;
    p.initialize = function (spellId) {

        this.Container_initialize();
        this.containerScale = new createjs.Container();

        this.SpellId = spellId;
        this.bm = new createjs.Bitmap(preload.getResult("i" + PortalCommon.RoomID + "_" + this.SpellId));
        this.addChild(this.containerScale, this.bm);
        this.bm.regX = 47;
        this.bm.regY = 47;
       
    };

    p.scaleEffect = function () {
        
        var im = new Array();
        for (var i = 1; i < 5; i++) {
            im.push(preload.getResult("as" + i));
        }
        var data = {
            images: im,
            frames: { width: 121, height: 123, regX: 0, regY: 0 },
            animations:
            {
                run: {
                    frames: [0, 1, 2, 3],
                    speed: 0.25
                }
            }
        };
        var spriteSheet = new createjs.SpriteSheet(data);
        var animation = new createjs.BitmapAnimation(spriteSheet);
        animation.gotoAndPlay("run");
        animation.x = -60;
        animation.y = -60;
        this.containerScale.addChild(animation);
        createjs.Tween.get(this.bm, { loop: false }).to({ scaleX: 0.7, scaleY: 0.7 }, 1000).to({ scaleX: 1, scaleY: 1 }, 1500);
    };
    p.scaleStop = function() {
        this.containerScale.removeAllChildren();
        createjs.Tween.removeTweens(this.bm);
        
    };

    window.Spell = Spell;

}(window));

(function (window) {
    function WinLine(lineId, itemId,matrix, lineItem, time) {
        this.initialize(lineId, itemId, matrix, lineItem, time);
    }
    var p = WinLine.prototype = new createjs.Container();
    p.Container_initialize = p.initialize;
    p.initialize = function (lineId,itemId, matrix, lineItem, time) {

        this.Container_initialize();
        this.LineId = lineId;
        var bm = new createjs.Bitmap(preload.getResult("l" + this.LineId));
        this.addChild(bm);
        this.x = Setting.Points[lineId - 1].x-47;
        this.y = Setting.Points[lineId - 1].y - 47;
        var i;
        createjs.Tween.get(this, { loop: false }).to({ alpha: 1 }, 1000).to({ alpha: 0 }, 100).wait(time).to({alpha:1},500).call(function() {
            for (i = 0; i < lineItem.length; i++) {
                var obj = matrix[lineItem[i].row][lineItem[i].col];
                if (obj.SpellId == itemId)
                {
                    obj.scaleEffect();
                }
            }
        }).to({alpha:1},2500).call(function(art) {
            for (i = 0; i < lineItem.length; i++) {
                var obj = matrix[lineItem[i].row][lineItem[i].col];
                if (obj.SpellId == itemId) {
                    obj.scaleStop();
                }
            }
            art.target.alpha = 0;

        });

    };
    window.WinLine = WinLine;

}(window));




